﻿using System;
using System.Collections.Generic;
using System.Text;
using Hkwl.WorldExpo.Merchant.Model;
using Hkwl.WorldExpo.Merchant.DataAccess;
using System.Collections;

namespace Hkwl.WorldExpo.Merchant.Service.Impl
{
    public class ClientServiceImpl : IClientService
    {
        private IClientDao infoDao;

        public ClientServiceImpl(IClientDao infoDao)
        {
            this.infoDao = infoDao;
        }

        #region NxClient 对象

        public NxClient GetNxClientById(int clientId)
        {
            return infoDao.GetNxClientById(clientId);
        }

        public int GetNxClientByCellphone(string cellphone, int merchantId)
        {
            return infoDao.GetNxClientByCellphone(cellphone,merchantId);
        }

        public bool InsertNxClient(NxClient client)
        {
            return infoDao.InsertNxClient(client);
        }

        public bool UpdateNxClient(NxClient client)
        {
            return infoDao.UpdateNxClient(client);
        }

        public bool DeleteNxClient(int clientId)
        {
            return infoDao.DeleteNxClient(clientId);
        }

        public IList<NxClient> GetNxClientCollection(int merchantId, int pageIndex, int pageSize, ref int count)
        {
            return infoDao.GetNxClientCollection(merchantId, pageIndex, pageSize, ref count);
        }

        public IList<NxClient> GetNxClientNotInGroup(int groupId,int merchantId)
        {
            return infoDao.GetNxClientNotInGroup(groupId,merchantId);
        }

        public IList<NxClient> GetNxClientInGroup(int groupId,int merchantId)
        {
            return infoDao.GetNxClientInGroup(groupId,merchantId);
        }

        /// <summary>
        /// 检测手机号是否有重复
        /// </summary>
        /// <param name="cellphone"></param>
        /// <returns></returns>
        public bool CheckNxClientByCellphone(string cellphone, int merchantId)
        {
            int client = infoDao.GetNxClientByCellphone(cellphone, merchantId);
            if (client >0)
            {
                return true;
            }
            else
            {
                return false;
            }
        }

        #endregion

        #region NxGroup 对象

        public bool InsertNxGroup(NxGroup group)
        {
            return infoDao.InsertNxGroup(group);
        }

        public bool DeleteNxGroup(int groupId)
        {
            return infoDao.DeleteNxGroup(groupId);
        }

        public IList<NxGroup> GetNxGroupCollection(int merchantId)
        {
            return infoDao.GetNxGroupCollection(merchantId);
        }

        public bool UpdateNxGroup(NxGroup group)
        {
            return infoDao.UpdateNxGroup(group);
        }

        public NxGroup GetNxGroupById(int groupId)
        {
            return infoDao.GetNxGroupById(groupId);
        }

        public int GetNxGroupCountByName(string groupName, int merchantId)
        {
            return infoDao.GetNxGroupCountByName(groupName, merchantId);
        }

        #endregion

        #region NxGroupClient 对象

        public bool InsertNxGroupClient(NxGroupClient groupClient)
        {
            return infoDao.InsertNxGroupClient(groupClient);
        }

        public IList<NxGroupClient> GetNxGroupClientCollection(int groupId, int pageIndex, int pageSize, ref int count)
        {
            return infoDao.GetNxGroupClientCollection(groupId, pageIndex, pageSize, ref count);
        }

        public bool DeleteNxGroupClient(int groupId, int clientId)
        {
            return infoDao.DeleteNxGroupClient(groupId, clientId);
        }

        public bool DeleteNxGroupClientByGroup(int groupId)
        {
            return infoDao.DeleteNxGroupClientByGroup(groupId);
        }

        #endregion
    }
}
